clear all
set emptycells drop
set matsize 11000
set maxvar 32670

*Set working directory
if c(username)=="" { //insert username
cd "" // insert root path
}

if c(username)=="jmc4qg" { 
cd "/Users/jmc4qg/The Lab Dropbox/Jonathan Colmer/ShotSpotter_env/Journal_submissions/ReStat/Replication Folder" 
}

if c(username)=="jonathancolmer" { 
cd "/Users/jonathancolmer/The Lab Dropbox/Jonathan Colmer/ShotSpotter_env/Journal_submissions/ReStat/Replication Folder"
}

use "Analysis Data/NIBRS_analysis.dta", clear

quietly: reghdfe homicide_pc prec if MP == 0, absorb(ori_sample_month week dow) cluster(fips) keepsingletons resid
predict hom_res_LP, res
quietly: reghdfe tMean prec if MP == 0, absorb(ori_sample_month week dow) cluster(fips) keepsingletons resid
predict temp_res_LP, resid
sum temp_res_LP, d
tw lpolyci hom_res_LP temp_res_LP if abs(temp_res_LP)<=10, legend(off) degree(0) ylabel(-0.005(0.0025)0.005, labsize(large)) ytitle("Homicides per 100,000 people""(Residuals)", size(large)) xtitle("Temperature (Residuals)", size(large)) xlab(-10(2)10, labsize(large)) yline(0) title("") fcolor(black) fint(20) lcolor(black) alwidth(none) lwidth(medthick)
graph export "Figures and Tables/Figure_2/Figure_2a.png", replace

quietly:  reghdfe homicide_pc prec if MP == 1, absorb(ori_sample_month week dow) cluster(fips) keepsingletons resid
predict hom_res_MP, res
quietly:  reghdfe tMean prec if MP == 1, absorb(ori_sample_month month dow) cluster(fips) keepsingletons resid
predict temp_res_MP, resid

sum temp_res_MP, d
tw lpolyci hom_res_MP temp_res_MP if abs(temp_res_MP)<=10, legend(off) degree(0) ylabel(-0.005(0.0025)0.005, labsize(large)) ytitle("Homicides per 100,000 people""(Residuals)", size(large)) xtitle("Temperature (Residuals)", size(large)) xlab(-10(2)10, labsize(large)) yline(0) title("") fcolor(black) fint(20) lcolor(black) alwidth(none) lwidth(medthick)
graph export "Figures and Tables/Figure_2/Figure_2b.png", replace

